12 Replies Latest reply on Nov 10, 2010 4:19 PM by gpriyanka

    retrieving properties from a MDB module

    c.carter

      hi,

       

       

       

      What I am trying to do is get the value of a property stored in MDB from within processbook. 

       

      Ideally the property's value would be stored in a VBA variable to used within the code.

       

      If there any simple way to do this, or do I have to get an PI-SDK connection to the MDB and retrieve the value that way?

       

       

       

      Thanks,

       

      Chris

        • Re: retrieving properties from a MDB module
          Bannikov

          Hello!

           

          The simplest way is use PI-SDK from VBA to retrieve property values from MDB. PI SDK Help contains useful samples (as I remember), so there's no problem to implement this.

          • Re: retrieving properties from a MDB module
            mheere

            Hi Chris,

             

            The simple way to do this is to place a 'current value' element onto the PB display and have it display the property value.  You can hide the element so that it doesn't show up to the users.  This element then becomes just another control on the display (which can be module relative it that helps you) which you can reference from within your code.

             

            The true benefit of using this approach is that it migrates transparently to AF.  If you write PI-SDK code in your VBA, then you have to go back and change it yourself to be AFSDK code when it comes time to migrate.  Using an element on the display, you let ProcessBook and OSIsoft figure out how to make that transition.  Your code can remain exactly the same :)

             

            Regards,

             

            Matt

              • Re: retrieving properties from a MDB module
                Ahmad Fattahi

                Smart one Matt! And the other benefit would be that the code underneath is already optimized. If one starts from scratch to retrieve properties using PI SDK, that’d not necessarily be the case. In other words, further trimming/optimization may be required afterwards.

                • Re: retrieving properties from a MDB module
                  gpriyanka

                  Matt Heere

                  The simple way to do this is to place a 'current value' element onto the PB display and have it display the property value.  You can hide the element so that it doesn't show up to the users.  This element then becomes just another control on the display (which can be module relative it that helps you) which you can reference from within your code.

                   

                  Matt,

                   

                  How would you refer to the property value? What is the code/syntax for it? I have aliases and properties whose values I want to select and use within the code.  

                   

                  Also, How can I refer to an existing dataset within PB whose name I know? I would like to edit its value using current context alias values. From what I understand Aliases cannot be used in datasets.

                   

                  Thanks,

                   

                  Priyanka

                    • Re: retrieving properties from a MDB module
                      dhollebeek

                      For what it's worth, if you write PI-SDK code to access the MDB, this code will still work after you upgrade to PI Server 2010 because the MDB is still maintained.

                      • Re: retrieving properties from a MDB module
                        mheere

                        Hmmm.  You probably don't want code samples from me .  Anyone have a quick sample they can post showing how to access the value of a control parked on a display?  IIRC the format is something like:

                         

                        Display.Controls("control name").value

                         

                        I don't know the answer to the data set question.  I might suggest that you start a new thread (or perhaps a moderator can do that for you) to ask a new question.  It will get better visibility in the community that way.

                          • Re: retrieving properties from a MDB module
                            dhollebeek

                            You can go with the Displays.Controls("name") route, but PB adds variables to your VBA project for each symbol you add.  So if your symbol is named "Value1", here it is:

                            'Print value, time, and status
                            Dim valueDate As Variant
                            Dim valueStatus As Variant

                            Debug.Print Value1.GetValue(valueDate, valueStatus)
                            Debug.Print valueDate
                            Debug.Print valueStatus

                            'Print just value
                            Debug.Print Value1.GetValue(Nothing, Nothing)

                            I didn't understand what you were trying to do with the dataset.  Maybe a little more backround/explanation?

                            • Re: retrieving properties from a MDB module
                              Ahmad Fattahi

                              You can refer to the Datasets using Datasets class. For example, GetDataset method retrieves the indicated dataset:

                              
                              

                              Datasets.GetDataset("DatasetNameHere")

                               

                              You may also want to check the SetDataset method for this matter. I would recommend you take a look at the chapter on "Datasets class" in the "PI ProcessBook VBA Language Reference" which explains all available methods relevant to Datasets.

                            • Re: retrieving properties from a MDB module
                              andreas

                              @Priyanka:

                               

                              you might want to take a look at the discussion Editing a Data set in Code or Creating a dataset in code

                               

                               

                              • Re: retrieving properties from a MDB module

                                Priyanka Gupta

                                How would you refer to the property value? What is the code/syntax for it? I have aliases and properties whose values I want to select and use within the code.
                                I think this topic went on a tangent by talking about VBA code... there is a simple, non-programmatic way to do this, for Module-Relative Displays. As Matt pointed out, you can simply drop a "Current Value" element on the display, then use the down arrow beside 'Tag Search' to select 'Module Context' instead, and finally select the property you want to display. This is being covered in the Module-Relative Displays section of the PI ProcessBook, PI DataLink and PI WebParts class, available under the vCampus Training Center.

                                 

                                Also, as far as the data set question, I think it might have been good to start a brand new discussion thread on the forum... answers are more accessible for readers when 1 thread = 1 question/topic. Just my 2 cents

                                  • Re: retrieving properties from a MDB module
                                    gpriyanka

                                    Thank you for your responses. I was able to use the GetValue Method to get the contents of a property in a VBA variable. Earlier I tried using GetPIValue but I got a data type error. The data type of the property was string and so was the variable defined.

                                     

                                    Andreas, I will look at the dataset discussions you have mentioned and continue my discussion there.

                                     

                                    Thank you

                                     

                                    Priyanka