Search code examples
serverosisoft

Osisoft pi data archive- How to create piServer collective


I am writing a c# application that uses OSIsoft AFSDK dll (2016 version). My application should define PI server collective and send data to this collective.
But what I'm trying to figure out is:
using C# code, how to define a PI data archive servers as a collective? and how to configure one of them to be the primary server?

I've been searching for code examples and couldn't find any code.
Can anyone post an example or a reference to such an example?


Solution

  • you can add a new Collective to the Known Servers Table using the next code snippet:

    using OSIsoft.AF.PI;
    PIServers myPIServers = new PIServers();
    PIServer newPIServer = myPIServers.Add("NewPIServer");
    

    Then you can access to PI Collective information using:

    PICollective collective = newPIServer.Collective
    

    You can consult the Live Library:

    https://techsupport.osisoft.com/Documentation/PI-AF-SDK/Html/T_OSIsoft_AF_PI_PIServers.htm

    And also there's a very good forum for anything regarding OSIsoft PI: https://pisquare.osisoft.com/

    Hope it helps!