13 Replies Latest reply on Oct 22, 2015 7:20 AM by Kenji Hashimoto

    Trend Tool

    sean.whittier

      Hey Everyone,

       

      Thought I would poll the community before we attempt to recreate teh wheel - so to speak.

       

      We are mid-implementation with PI, replacing a competitor historian system.  This competitor offered a very simple trend tool that could be called via command line, and pop-up a window that trended points for the last 24 hours.  Our operators use this to call-up historical trends from our SCADA display.

       

      We have tried a few things to replicate this functionality.  We have called coresight which would in turn pull up a dynamic display, but loading up the browser, and coresight is much too slow.  We are now working to write our own via the the AF-SDK, but our prototive is VERY basic right now (thus the question).

       

      So, the question is.  Have any of you developed a windows forms based trend that you would be willing to share and / or discuss with us as we develop our own solution?

       

      Any help is welcome - thanks!

        • Re: Trend Tool
          Kenji Hashimoto

          You can use PI ProcessBook to show the Trend. (With high speed)

          The default trend shows (*-8h to *) but you can change it.

          Tools > Preferences > Trend tab > Plot Scale > Start (You can put *-24h)

          So after this settings, drawing trend's default shows 24 hours.

          I hope you can find a way with PI ProcessBook.

          • Re: Trend Tool
            HenlodeWaal

            We designed our own ProcessBook add-in that does something similar. Basically if you click on any object within PB and it has a tagname it will trend it for you. We create this trend using a predefined pdi file. So, if I click on sinusoid on display1 it will open this file add sinusoid to this trend, then I can open any other display and just keep clicking away and it will add these tags to the trend. So now you can compare tags from different displays, instead of copying and pasting data from different displays. We also added an annotation writer as well as save as jpg on this predefined pdi file.

            • Re: Trend Tool
              sean.whittier

              Do either of you know if ProcessBook can be called from the command line to display these trends?  I have a feeling our operators would be opposed to keeping both applications open on their desktop at all times.

                • Re: Trend Tool
                  Kenji Hashimoto

                  You can boot the PI ProcessBook display by just call pdi file from command prompt.

                  (If the file locaition is C:\temp\display1.pdi)

                  Command should be:

                  c:\temp\display1.pdi

                  Does it work?

                    • Re: Trend Tool
                      sean.whittier

                      That works, but I still can't pass the point name to the display.  The operator would need to search for the point again.  Do you know a way to pass the point name you are hoping to trend?

                          • Re: Trend Tool
                            sean.whittier

                            Thanks Andre,

                             

                            We have been working with Coresight, but it is currently taking about 30 seconds from request to trend.  We will continue to see if we can't get that time down, but are evaluating other options at this point as well.

                              • Re: Trend Tool
                                gregor

                                Hello Sean,

                                 

                                How about creating a command line application that takes a PI Point Name or AF Attribute Path as input parameter, stores that information locally in a text file and launches ProcessBook with a predefined display. The Display would need some VBA code that reads the PI Point Name / AF Attribute Path from file and e.g. adds a Trace to an existing Trend. Could that work for you?

                                  • Re: Trend Tool
                                    sean.whittier

                                    Thanks Gregor,

                                     

                                    That's exactly where we are.  Instead of using VBA though, we are writing something up in .NET using the AF SDK.  I know we can't be the first to do this, so this question was put on here to see if anyone else has done the same, and if they were willing to talk or share. 

                                      • Re: Trend Tool
                                        Kenji Hashimoto

                                        This thread talks about displaying trend by .net.

                                        Re: PI Trace in .Net

                                        • Re: Trend Tool
                                          gregor

                                          Hello Sean,

                                           

                                          I wouldn't know what you need AF SDK for but you may have additional functionality in mind that you haven't spoken about yet. The following VB.Net code should be at least very close to what you are looking for. I've tried doing the same in C# but wasn't able to figure out the right way to add the trend. You need to add a reference to COM libraries PBObjLib and PBSymLib. It appears Visual Studio is also adding references to PI SDK, PI SDK Common and PI TimeServer but you can remove them later.

                                          This console application expects the data item reference submitted as the first command line parameter. Either a PI Point Name or an AF2 Reference (AF2.\\<AFSERVER>\<Database>\<Element>|<Attribute>) can be used. Users should enclose references into double quotes to avoid they become recognized as multiple command line arguments. Additional command line arguments become ignored. You can set size and position of the trend by properties Top, Left, Height and Width but I believe a maximized trend fits best for your add-hoc use case.

                                           

                                           

                                              Sub Main()
                                                  ' Launch PI ProcessBook
                                                  Dim myApplication As New PBObjLib.Application()
                                                  ' Wait for ProcessBook to become ready
                                                  Dim iReady As Integer = myApplication.ReadyState
                                                  Do While (myApplication.ReadyState <> iReady)
                                                  Loop
                                                  ' Create new display
                                                  Dim myDisplay As PBObjLib.Display = myApplication.Displays.Add("New Display")
                                                  ' Maximize display
                                                  myDisplay.Maximize()
                                                  ' Add trend
                                                  Dim myTrend As PBSymLib.Trend = myDisplay.Symbols.Add(PBObjLib.pbSYMBOLTYPE.pbSymbolTrend)
                                                  ' Add the a trace for the data item
                                                  Dim myDataItem As String = My.Application.CommandLineArgs(0)
                                                  myTrend.AddTrace(myDataItem)
                                                  ' Set the time range
                                                  myTrend.SetTimeRange("*-24h", "*")
                                                  ' Maximize trend
                                                  myTrend.Maximize(True)
                                                  ' Revert time ranges - not necessarily needed
                                                  myDisplay.Revert()
                                              End Sub
                                            • Re: Trend Tool
                                              gregor

                                              Sorry,

                                               

                                              Task Manager appears more relaxed with this small modification:

                                               

                                                      ' Wait for ProcessBook to become ready
                                                      Dim iReady As Integer = myApplication.ReadyState
                                                      Do While (myApplication.ReadyState <> iReady)
                                                          System.Threading.Thread.Sleep(100)
                                                      Loop