5 Replies Latest reply on Sep 7, 2017 12:41 AM by Eugene Lee

    How to access AF server using PIserver.PIsystem property

    amitvankudre

      Hi,

       

      I am using AFSDK and trying to access the PI AF Server associated with one of our PI Data Archives. I am using the PIServer.PISystem property of the PIServer class of OSISoft.AF.PI namespace. However it is returning a null value. Below is my code :

      ---------------------------------------------------------------------------------------------------------------

      objPIServer = objPIconnect.ConnectPI(AFServerBox.SelectedItem.ToString()); // PIserver object;the ConnectPI() method connects to the PI server and returns the server in objPIServer object

      var x = objPIServer.PISystem;

      ----------------------------------------------------------------------------------------------------------------

       

      The x evaluates to null.Can someone confirm why so ? I need to either access the PI Data archive associated with an AFServer or vice versa.

       

      Appreciate any help in this regard.

       

      Thanks

      AMit Vankudre

        • Re: How to access AF server using PIserver.PIsystem property
          John Messinger

          Hi Amit,

           

          I've never seen a PISystem property on a PIServer object, nor do I see it documented anywhere in the AF SDK documentation. Perhaps this is why the object is returning null in your code.

           

          Further to this, I'm not aware of a 'hard' relationship between PISystem and PIServer. A PI Data Archive can be 'associated' to multiple AF servers (although only one has any form of explicit relationship for PI-MDB synchronisation), and a PI AF server can have multiple Data Archives 'associated' to it.

           

          What exactly are you trying to do here? You mention that you "need to either access the PI Data archive associated with an AFServer or vice versa" - which is it, and what are you looking to do with that connection?

           

          Regards,

          John

            • Re: How to access AF server using PIserver.PIsystem property
              amitvankudre

              Hi John,

              I am preparing a windows forms tool where the user can input either the data archive or the af server which he intends to connect to. I do not want to take inputs for both the data archive and af server, it should be either one of these and then the code should figure out the other attached component.

               

              I believe that each AF server will have a data archive associated with it since while installing the af server we need to specify the data archive it is supposed to connect to.

               

              Secondly if you check out the PIServer class of the Osisoft.AF.PI namespace of AF SDK it has a property called "PI System". This should ideally be the one through which we can connect to the associated AF server.

               

              Thanks

              Amit

                • Re: How to access AF server using PIserver.PIsystem property
                  John Messinger

                  Hi Amit,

                   

                  The PISystem property in PIServer is inherited from AFObject, being the base class for all of the objects in AF SDK. I'm going to suggest it is returning null in your code as there is no reason for it to be set to a non-null value in relation to a PIServer object. For other objects such as AFElement, AFDatabase etc, it makes sense for these to have a PISystem set in their inherited property, as they are child objects of a PISystem, whereas PIServer does not have a PISystem as a parent object.

                   

                  As I mentioned earlier, there is no direct association between PISystem (AF Server) and PIServer (PI Data Archive) at the SDK level. When installing PI AF and you are asked to specify a PI Data Archive, this does not set a relationship that is then reflected explicitly through the AF SDK (via the PIServer property inherited from AFObject). It is effectively like setting a default connection as is done with all other client applications. Like I said, there can be a many to many relationship between AF servers and Data Archive servers, managed through the known servers table, and exposed in the AF SDK via the PIServers and PISystems global object collections. PIServer and PISystem are effectively both top level objects, and are not containers for the other.

                   

                  If you are working with only single instances of both PIServer and PISystem objects, you could probably just connect to the default server in the collection. If this isn't the case, you may need to map your own relationships between the two server types.

                   

                  Regards,

                  John

                  1 of 1 people found this helpful