27 Replies Latest reply on Aug 4, 2011 9:48 PM by cjrancur

    Set all trends for all displays in ProcBook to use same start and end time

    cjrancur

      I recall a demo showing that all Process Book trends within a given display could be selected and set to the same start and end time.  I don't know if there is such a handy tool included for all displays in a Process Book.  I'd like to find or build one.

       

      I am considering making an initial page in the ProcBook, and putting 2 datepicker controls on it, one for start and one for end.  Then connecting all trends in the book to get their start and end time from this.

       

      The reason I want this is that I must do a monthly report of certain process events and control status.  The report goes from 9 am on the 15th of one month, to same time on the next month.  If the 15th falls on a weekend or vacation, or even if I'm working on the report in the afternoon of the 15th, I'd like to see only the data for the period I'm reporting on, so that I don't muddle the report with things happening earlier or later.  Every month, I go through about 30 trends and update the start and end times.  Since I do it monthly, it makes sense to automate this, if I have a few minutes to do it.

       

      I have built a good datalink spreadsheet that gets most of the data, but I don't like datalink trends.  Maybe they are better now, but years ago, they'd cause datalink to crash, and you couldn't do as much with them as easily, like zoom or use a data cursor.  I'd rather use a process book trend, because of all the nice features OSIsoft provides for PB trend.

       

      If there is already a built in way to do this,  please let me know.  I'm starting to build vba code to do this, but if it's not necessary, I'd rather use an OSIsoft prebuilt method.

        • Re: Set all trends for all displays in ProcBook to use same start and end time
          cescamilla

          I don't want to discourage your efforts...

           

          but if you do set the timerange in processbook all the items selected (or all items if none are selected) will set they start and end time to those values.

           

          This is already included in ProcesBook since version 2.14 or something like that.

           

          Does this help you?

            • Re: Set all trends for all displays in ProcBook to use same start and end time
              cjrancur

              Cristobal Escamilla

              if you do set the timerange in processbook all the items selected

               

              Thanks Cristobal, that may be what I'm looking for.  I don't know how to set the timerange in PB to all the items selected.  If I selected all pages in an outline format, for example, can I right click and get a choice about setting the timerange for all?

                • Re: Set all trends for all displays in ProcBook to use same start and end time
                  cescamilla

                  It works in run mode (not in build mode) and if you make sure nothing is selected, the time range control will set the start time and end time for everything in the PDI.

                   

                  note that is will only work while on run mode and the changes can't be saved.

                    • Re: Set all trends for all displays in ProcBook to use same start and end time
                      cjrancur

                      In run mode, if I select nothing but only open a PIW, I see that all time controls are greyed out, and right click only gives the choice between outline and book view in PB version 3.2.0.0.  I've apparently missed a step.  What do I need to do before the range control will be enabled? 

                        • Re: Set all trends for all displays in ProcBook to use same start and end time
                          cjrancur

                          I also tried opening a single display, clicking in the white space outside the trend, and then adjusting the time range.  When I closed that display within the piw, the next display I opened did not have the previously selected time range.  Next, I tried just minimizing the first display.  The next display I opened did not have the previously selected time range. 

                            • Re: Set all trends for all displays in ProcBook to use same start and end time

                              Hi Carrie,

                               

                              The time range controls are only applicable to a display not a workbook.  Even with a display, you need to have a symbol on the display that can use a time range to enable the controls.

                               

                              Having said that, if you want to be able to set this each time you open your displays then maybe VBA is your answer..?  If so, following VBA will update all Trends in your display.  Just call if from the Display_Open even in the display(s) so they always set the timerange.

                              
                              

                              Private Sub Display_Open()
                                  Call UpdateAllTrends
                              End Sub

                              Private Sub UpdateAllTrends()

                              Dim Sym As Symbol
                              For Each Sym In ThisDisplay.Symbols
                                  If Sym.Type = pbSYMBOLTYPE.pbSymbolTrend Then
                                      Call Sym.SetTimeRange("*-1h", "*")
                                  End If
                              Next Sym

                              End Sub

                               

                                • Re: Set all trends for all displays in ProcBook to use same start and end time
                                  cjrancur

                                  Thanks Rhys,

                                   

                                  I'll try that.  Since I have many displays, I think I may put the subroutine into a separate module, so I don't have 30 copies, one for each display.  Or maybe I'll figure out how to do this upon opening ANY display within the same process book, without putting the Call UpdateAllTrends line onto each display's VBA sheet.  I may still use the time pick control.  If so, the display that has that control might be a place to put the Sub UpdateAllTrends.  Can PB VBA use the Friend Sub syntax, or would I have to use Public Sub syntax to do something like that?

                                   

                                  Carrie

                                  • Re: Set all trends for all displays in ProcBook to use same start and end time

                                    Hi Carrie,

                                     

                                    Your first post lead me (and Cristobal too I think!) to believe that you were talking about a display file (.PDI) rather than a workbook file (.PIW): "all Process Book trends within a given display could be selected and set to the same start and end time".

                                     

                                    As Rhys pointed out, those time controls can only affect one display at the time, the active one. And as Cristobal pointed, those are "Run mode" type of changes, which means they are not persisted when you close/save the display.

                                     

                                    With that said, VBA (or a .NET ProcessBook add-in) will be your friend in this case. Rhys already gave you the code to update all trends within a display - now you need to do with all displays within a workbook.

                                     

                                    Given I have the following workbook with the "TimeSetter" display entry as follows:

                                     

                                    100212_2D00_WorkbookWithTimeSetterDisplay.png

                                     

                                    Then the button you see there might have code as follows:

                                    Dim oEntry As PBObjLib.Entry
                                    Dim oDisp As PBObjLib.Display
                                    Dim oSymb As PBObjLib.Symbol
                                    Dim oTrend As PBSymLib.Trend
                                    Dim idx As Integer

                                    'Find the "label" of the current display
                                    Dim strThisDisplayLabel As String
                                    strThisDisplayLabel = Right(ThisDisplay.Path, Len(ThisDisplay.Path) - InStr(1, ThisDisplay.Path, "!", vbTextCompare))

                                    'Open all "Embedded Display" entries in the current Workbook
                                    '(except the current one)
                                    For Each oEntry In ActiveProcBook.Entries
                                        If oEntry.Type = pbEntryPDIEmbeddedInLocalPIW And oEntry.Label <> strThisDisplayLabel Then
                                            oEntry.Execute True
                                        End If
                                    Next

                                    'Browse through all open display entries in the Workbook
                                    For Each oDisp In ActiveProcBook.Displays
                                        'If it is not the current display (where this VBA code resides)
                                        If oDisp.Path <> ThisDisplay.Path Then
                                            'Browse through all symbols in that display entry
                                            For Each oSymb In oDisp.Symbols
                                                'If the type of that symbol is "Trend"
                                               If oSymb.Type = pbSYMBOLTYPE.pbSymbolTrend Then
                                                    'Set the trend's start and end times to the
                                                    'user-specified values entered in the 2 text boxes
                                                    Set oTrend = oSymb
                                                    oTrend.SetStartAndEndTime ThisDisplay.txtStartTime.Text, ThisDisplay.txtEndTime.Text
                                               End If
                                            Next
                                            'Close this display and save it
                                            oDisp.Close (True)
                                        End If
                                    Next

                                    Hope this helps!

                                      • Re: Set all trends for all displays in ProcBook to use same start and end time
                                        cjrancur

                                        Steve Pilon

                                        I have the following workbook with the "TimeSetter" display entry as follows:

                                         

                                        The proposed code works.  It is a great timesaver.  Thanks, Steve.

                                         

                                        And I apologize for the confusion from my original post. I already knew that a utility was built in to Process Book for setting all times for various time sensitive PB controls in a given display to the same value. I had seen a demo on that in a regional PI seminar. I guess I should not have tried to lead off with a statement of contrast. I meant to say, "I know this can be done for a single display, but how do I do this for all displays in a workbook?"

                                         

                                        I also used the term ProcessBook interchangeably with ProcessBook workbooks, and I used the term Process Book display to indicate a single display, either as a standalone or within a workbook.  I've learned from you and Cristobal that is not exactly correct usage.  That contributed to the confusion.  I'll be more specific to say workbook, not ProcessBook, when I'm referring to a Process Book workbook.  The symbol of a ProcBook as a spiral bound notebook probably contributed to my generalization, where I equated a ProcessBook with a ProcessBook workbook.  The icon makes me think of a workbook of several displays, since the icon looks like a bound edition of many displays. I'm sorry I didn't make my question very clear in the initial post.  I understand that the ProcessBook client runs both the workbooks and the individual *.pdi displays, so I see why I should not have assumed that saying "ProcessBook" was identical to saying "ProcessBook workbook".

                                      • Re: Set all trends for all displays in ProcBook to use same start and end time

                                        Rhys @ RJK Solutions

                                        Sym.SetTimeRange("*-1h", "*")
                                        Be careful which of the Trend.SetTimeRange or Trend.SetStartAndEndTime methods you use... the former will set the "run time" time range (i.e. will not be persisted when closing/saving the display) whereas the latter changes the actual "build mode" configuration of the trend.

                                         

                                        Cheers!

                              • Re: Set all trends for all displays in ProcBook to use same start and end time
                                cjrancur

                                Hi Cristobal,

                                 

                                Can you tell me the dll where the DateTimePicker exists?  I found out about the DateTimePicker control from your August 2009 blog.

                                 

                                I can find a DatePicker, but so far I have not found the DateTimePicker you mentioned in your August 2009 blog.  I'd like to be able to select both date and time.

                                 

                                Is there a resource somewhere, either online or offline, for finding items in dll's that are not included in a given project?  I'm looking for a super set Object Browser, for all available objects, not just for objects included in dll's within a given project.  Currently, object browser for my project is not finding the datetimepicker for my process book installation, and I don't know which reference to add to find the DateTimePicker control.

                                 

                                Carrie Rancuret

                                  • Re: Set all trends for all displays in ProcBook to use same start and end time
                                    cjrancur

                                    Googled it.  Found out that the datetimepicker is in the system.windows.forms.dll. 

                                     

                                    Still would like to know if there's a better way to find which dll contains a given control, rather than resorting to a search engine.  Maybe that's the best way?

                                      • Re: Set all trends for all displays in ProcBook to use same start and end time

                                        Carrie Rancuret

                                        Googled it
                                        Did you Google it or you "googled it with Bing"?

                                          • Re: Set all trends for all displays in ProcBook to use same start and end time
                                            cjrancur

                                            Bing ==> TCP/IP Ping with a stuffy nose?  A crooner that sure could sing, Crosby style?

                                             

                                            Maybe I should have binged, (bonged? bingetted?).  Because after I added Microsoft Forms 2.0, I still get only a "DateTimePickerAccessibleObject", but I haven't found the control yet.  I'll Bing it and see if that gets anywhere.  Google directed me to MSDN, so I thought I had it.  Not quite. 

                                             

                                            If anyone knows what library to add to get the DateTimePicker control, please let me know.  I'm still looking.

                                              • Re: Set all trends for all displays in ProcBook to use same start and end time

                                                I think you want to look in the mscomct2.ocx control library...
                                                this is the window you get when adding the DateTime Picker as an ActiveX Control in ProcessBook

                                                 

                                                100212_2D00_DateTimePickerControl.png

                                                 

                                                Is that what you are looking for?

                                                  • Re: Set all trends for all displays in ProcBook to use same start and end time
                                                    cjrancur

                                                    I would never have known to look in mscomct2.ocx.  It seems like this sort of thing should be published somewhere.  Anyway, I'm glad I have vCampus to help me find my way through the maze of references.  Seems like a good software company might make some $$$ by helping developers out with this sort of search.  Or am I the only one that would never have thought to look for a DateTimePicker in mscomct2.ocx?  Silly me.

                                                     

                                                    Next step, I looked for mscomct2.ocx in my references, and did not find it.  I found a reference that mentioned Microsoft Com objects.  That was not it.  I looked in c:\windows\system32\ and did not find it.  I found a place to download it from Bing.  To my surprise,  the download was not from Microsoft.  Haven't tried downloading yet.  Will search my PC later to see if the file is there, and then see if I can find it directly by a search of MSDN download center.

                                                     

                                                    Thanks Steve, for pointing me to the file name.  Hopefully I'm now  one step closer in this search.

                                                  • Re: Set all trends for all displays in ProcBook to use same start and end time

                                                    Carrie Rancuret

                                                    Maybe I should have binged, (bonged? bingetted?)
                                                    My vote goes for bingetted

                                                    • Re: Set all trends for all displays in ProcBook to use same start and end time
                                                      cjrancur

                                                      Bing brought bilious bubbly blurbs.  Bing and Google sent me to the same place as top pick. It looks to me like the DateTimePicker should be in the .Net framework.  I've got lots of versions of the .net framework on my PC.  But I don't see any libraries that say Framework when I go to tools, references in PB vba.  Is the required library accessible to Process Book? Or maybe it requires vb.net outside of Process Book? What would Microsoft have called the framework?  (Bang!?) I'm going to try to browse to the windows system directory where I have found the various .Net framework versions before, and see if I can find an appropriate dll to add.  Should it be this hard to find?

                                                        • Re: Set all trends for all displays in ProcBook to use same start and end time

                                                          Carrie,

                                                           

                                                          The fundamental thing need you need to keep in mind here is that there are 2 distinct realms in the Windows programming world:

                                                          • COM (Component Object Model)
                                                          • .NET

                                                          And while there are ways to have them interoperate, they are separate technologies and are normally used separately (i.e. COM with COM and .NET with .NET). Two good examples of interoperability in the PI world are .NET add-ins in PI ProcessBook (which is COM-based) and the PI SDK used in .NET (the PI SDK originally is a set of COM libraries, on top of which we created .NET Interops).

                                                           

                                                          Then there also is a fundamental difference between embeddable objects that do have some User Interface (UI) - generally referred to as ActiveX controls in the COM world and User Controls in the .NET world - and those that do not. For instance, when you use the "Control" tool on the Drawing toolbar, in PI ProcessBook (which is a COM-based product) 100215_2D00_ControlOnDrawingToolbar.png you get a list of the COM ActiveX controls registered on your machine - including the Microsoft Date and Time Picker. This ActiveX control is implemented in the C:\WINDOWS\system32\mscomct2.ocx, along with other ActiveX controls: Animation, UpDown, MonthView and Flat ScrollBar.

                                                           

                                                          With that said, a similar control is available for .NET applications: the DateTimePicker class, which inherits from the Control class, implemented in the System.Windows.Forms.dll assembly. Don't try to find this one on your file system: it is registered in the Global Assembly Cache (GAC), viewable at C:\WINDOWS\Assembly.

                                                           

                                                          You also talked about the list of items you get when you selected Tools > References in the ProcessBook VBA Editor... the list you get there consists of COM libraries that implement objects (classes) with no UI.

                                                           

                                                          Should you have more questions on this topic, I invite you to use the General .NET Development discussion forum - I'm sure this may help others as well

                                                            • Re: Set all trends for all displays in ProcBook to use same start and end time
                                                              cjrancur

                                                              Since ProcBook is com based, I wonder if this community could weigh in on the following topic.  Is Microsoft, and as a partner, OSIsoft, moving away from use of .COM objects in favor of ,NET objects?  And if so, how quickly is that change expected to occur?

                                                               

                                                              What is the useful expected lifetime of .COM objects like the DateTimePicker?  Are there any indications that a ProcessBook VBA application using DateTimePicker now may not be useful in 5-10 years due to obsolence of the ActiveX COM control object?

                                                               

                                                              If this is so, would it be smart to avoid ProcessBook VBA coding that uses .COM objects, like the mscomct2.ocx ActiveX DateTimePicker under the "Control" tool in the Drawing Toolbar of ProcessBook?

                                                                • Re: Set all trends for all displays in ProcBook to use same start and end time

                                                                  Carrie Rancuret

                                                                  Is Microsoft, and as a partner, OSIsoft, moving away from use of .COM objects in favor of ,NET objects?
                                                                  Yes, definitely. At least for the "visual" type of applications (i.e. the PI Server, for example, is likely to remain in COM-based code).

                                                                   

                                                                  Carrie Rancuret

                                                                  how quickly is that change expected to occur?
                                                                  It started back in 2002 (with the release of the .NET Framework v1.0) and will most likely take many more years to complete... if it ever completes.

                                                                   

                                                                  Carrie Rancuret

                                                                  What is the useful expected lifetime of .COM objects like the DateTimePicker?  Are there any indications that a ProcessBook VBA application using DateTimePicker now may not be useful in 5-10 years due to obsolence of the ActiveX COM control object?
                                                                  This one is nearly impossible for us to answer: it all depends on how long you and your organizatoin are going to be using PI ProcessBook in its COM-based nature (and there are no plans to port it to .NET as this time).

                                                                   

                                                                  Carrie Rancuret

                                                                  would it be smart to avoid ProcessBook VBA coding that uses .COM objects, like the mscomct2.ocx ActiveX DateTimePicker under the "Control" tool in the Drawing Toolbar of ProcessBook?
                                                                  It depends on what you need:

                                                                  • If you just need to drop a control or two on a display and have a bit of interaction going on, then it is probably easier for you to just using the "Control" tool of the Drawing toolbar - and some VBA code. This implies you are using COM controls.
                                                                  • If you need something a little more involved (e.g. a docking window, a new toolbar or toolbar button), then you definitely want to go the .NET route and code a .NET ProcessBook add-in (see this webinar for more information).