9 Replies Latest reply on Mar 10, 2011 8:57 PM by spilon

    Creating trends on PB entries

    cjrancur

      I am looking for appropriate syntax for the PB VBA "Entry DefineMethod"  szAction and szDirectory parameters.  My PB VBA language reference documentation file is from 2007, maybe I need to update.  I'll do that, but I wanted to see if maybe a guru on this forum could help me with my general task.

       

      I am asking because  I want to build a PB with links to 136 similar trends.  Rather than using a module for each (we only have 156 PI tags remaining on our license,  OWWWH!, and money is scarce for upping the ante), I am working out a way to automate this rote task in PB.  I've figured out how to make 136 separate pdi displays with the trends in the format I want using PB VBA.  But I'm stumped on doing the similar project with entries within a piw file, instead of as separate pdi displays. Yes, I could copy/paste 136 pdi files into a piw, but I don't want to.  I'd like to have a routine that I might use for later, similar projects also.

       

       I haven't yet figured out how to make an equivalence between a display, and an entry.  I know that an entry is a higher level object than a display, and an entry can take the form of a text, a display or a link.  Yet getting a display object from an entry object is so far something that I haven't mastered.  I'd really appreciate help on it.  In the meantime, the Entry.Path string may give me some clues on the format for szAction and szDirectory.  I'll fiddle with some more trial and error, but so far, that has not led me to success.

       

      Thank you for your help,

       

      Carrie Rancuret

       

       

        • Re: Creating trends on PB entries
          cjrancur

           

           

          6153.references.png

           

           

           

          Update from Carrie -

           

           

           

          I found part of the answer, but not all.  Use empty strings for the required 2nd and 3rd parameters of the Entry.DefineAction method, like this:

           
          Set oEntry = ActiveProcBook.Entries.Add(strDisplayName)
          oEntry.DefineAction 1, "", ""
          

           "", ""

           

          After that, I still am trying to work out how to obtain the display object from the entry object.  I wonder if I have added the right reference dll's yet, because object browser cannot yet locate the enumerator pbLinkOptions.  I don't need that particular object anymore, since I've found the way to define an entry as a dialog, but maybe the object I need is in a similar library that I haven't tried to add as reference to my project.

           

           

            • Re: Creating trends on PB entries
              cjrancur

              I will add one more addendum to this post. (It feels like talking to myself...  

               

              I think I have an idea for configuring the display within the entry.  I will try this:

               

              1) Use the "Entry.Execute False" to open the Entry that was defined as a display.

               

              2) Use a for/next search of Displays with the ProcessBook objects, and use istr VBA function to find a label or path that includes the name of the entry I created as display.  Use that Display object to build trends.

               

              I have not tried it yet.

               

              Something else that gave me trouble, I tried to use the following command:

               

              oEntry.SetLevel(2)

               

              But I received an error saying that the index was outside the bounds of the array. Documentation says levels 1-10 should be OK.  I found the level object so I will define it as that object next, and see if that helps.

               

              Adventures in OOPs ( Object Oreinted Programming Struggle = OOPs),

               

              Carrie

                • Re: Creating trends on PB entries
                  dlunasin

                  You first need to create your entries and then once they are created set the level.

                   

                  Here is a simple example, that hopefully makes sense:

                   
                  Private Sub CommandButton1_Click()
                  
                      Dim newBook As ProcBook
                      Dim newDisp As Display
                      Dim newEnt As Entry
                      Dim newTrend As Trend
                  
                      Application.ProcBooks.Add ("Test")
                      Set newBook = Application.ActiveProcBook
                  
                      For i = 1 To 10
                         Set newEnt = newBook.Entries.Add("TestEntry" & Str(i))
                         newEnt.DefineAction 1, "", ""
                         newEnt.Execute (True)
                         Set newDisp = Application.ActiveDisplay
                         Set newTrend = newDisp.Symbols.Add(pbSymbolTrend)
                         newTrend.AddTrace ("sinusoid")
                         newDisp.Save
                         newDisp.Close (False)
                      Next i
                  
                      'Set the created entries to level 2 
                      For i = 2 To 10
                         newBook.Entries(i).SetLevel 2
                      Next i
                  
                  End Sub
                  

                   

                    • Re: Creating trends on PB entries
                      cjrancur

                      Thank you Daniel,

                       

                      That helped a lot.  I have 136 trends now. Activating the display, and then setting newDisp to point to the ActiveDisplay was the key to getting the Display object. 

                       

                      I had some trouble with SetLevel, until I realized that I could not set the level to 2 unless there was at least one Level 1 entry above the entry to be set to level 2.  I started to use the entries.insertafter, instead of entries.add, so that the new entries would be below a top level entry at Level 1, not above it.  After that, the SetLevel method worked fine without using a second loop.  Also, the entries were then listed numerically, from 1 to 136, not from 136 to 1.

                       

                      Thank you very much for the example.  It was just what I needed to get this done.

                       

                      Carrie

                        • Re: Creating trends on PB entries
                          dlunasin

                          No problem. Glad I could help :)

                            • Re: Creating trends on PB entries

                              Hi Carrie...joined your issue late in the day after you got the answer you need from Daniel, but I couldn't help but post to query if creating a PIW with 136 links to trends is the most efficient way to tackle your scenario.  I guess you don't have AF due to your reliance on the Module Database - Element Relative Displays would solve your issue with 1 display.  It might be an option to have a single display that reads in from a table or xml file to generate the trends on demand, but difficult to say without understanding the need and future usage of organising so many trends.

                               

                              I like reading your posts as they are always so well written - even if you do talk to yourself a lot.

                                • Re: Creating trends on PB entries
                                  cjrancur

                                  Hi Rhys,

                                   

                                  Does AF require a tagstream for each configuration, like the module database needs a tagstream for each alias?

                                   

                                  Because the module database requires a tagstream count for each alias, I did not use it due to licensing usage constraints.  I also hesitate to build another application using the module database because we plan to move to AF fairly soon.  I did not want to create an unnecessary migration issue.  The problem was, we needed these displays before AF could be installed.

                                   

                                  I really appreciate your compliment, because I have been focusing on improving my writing lately. My writing has not always been good , but it's getting there .  I have a coach to thank for this, from a business called WriteAdvantage.  Thank you again, your compliment warms my heart.

                                   

                                  Carrie

                                    • Re: Creating trends on PB entries
                                      Ahmad Fattahi

                                      Carrie,

                                       

                                      Your existing PI tags could be referenced in your AF Server through element attributes. So you would create an element with a number of attributes. Each attribute would have a reference.  Among the possibilities is PI tag. This will sit on your AF Server only (and not on the PI Server) and hence would not count against your licensed tag counts. Hope this answers your question

                                        • Re: Creating trends on PB entries

                                          And to answer your questions around data stream count:

                                           

                                           - No, AF Elements and Attributes do not count as data streams.

                                           

                                           - Slight correction on your post: PI Module Database Aliases do not count as data streams... only Modules do.

                                           

                                          If you are still hesitant about this, I would like to add my vote to "absolutely don't build a Module Database application today, to migrate it later - build it using AF".