AnsweredAssumed Answered

Connecting to the non-primary PI server from AF SDK

Question asked by p.clemme on Apr 25, 2016
Latest reply on Apr 26, 2016 by p.clemme

Hi there

I am doing an export using the AF SDK and attributes in PI. The export is putting a heavy load on the PI Server.

 

 

We have a setup with a singe AF Server and two PI servers, where one is the primary server.

 

 

When running the export I would really like to have the data retrieval to connect to the secondary server.

 

 

 

In the AF SDK on live library I can find a description on how to connect to specific AF server (PI System) and also on how to connect to a specific PI Server.

 

I cannot however see how I can get data from the secondary PI Server through Attributes in AF SDK.

 

 

My idea was that if I just connect to the PI server I want in my program, the AF SDK will use that connection.

This is however not what I get. I always seem to run the queries on the primary PI Server.(I can see it using the PI SMT- PI Services)

 

 

Can anyone help me to reach a specific PI Server through AF Attriutes using AF SDK?.

 

 

I have done the following in code

 

        public static PISystem GetPiSystem(string name)
        {
            PISystem system;

            var systems = new PISystems();
            PIConnectionInfo.DefaultPreference = AFConnectionPreference.Any;

            if (String.IsNullOrEmpty(name))
                system = systems.DefaultPISystem;
            else
                system = systems[name];
            return system;
        }

 

        public static PIServer GetPiServer(string name)
        {
            PIServer server;
            var piServers = new PIServers();
            //AFConnectionPreference.Any;
            server = piServers.DefaultPIServer;
            if (!string.IsNullOrEmpty(name))
            {
                server = server.Collective.Members[name].PIServer;
            }
            return server;
        }

        private AFDatabase _afDatabase;
        private PIServer _piServer;

        public DataAccess(string afServerName, string afDatabaseName, string preferredPiServer)
        {
            _piServer = GetPiServer(preferredPiServer);
            _piServer.Connect(true,null);

            _afDatabase = GetPiSystem(afServerName).Databases[afDatabaseName];
        }

 

 

 

Based on the what is described in the live library.

Connect to AF Server

// Get the PISystems collection for the current user and default PISystem.

PISystem myPISystem = new PISystems().DefaultPISystem;

// Simple connect.

myPISystem.Connect();

 

//Connect to a specific PI Server

PICollectiveMember myMember = myPIServer.Collective.Members[0];

myMember.Connect(true, null);

Outcomes