AnsweredAssumed Answered

How to verify on a collective that the primary member is available

Question asked by Noga on Sep 10, 2018
Latest reply on Sep 13, 2018 by Rick Davin

I am using AF-SDK in my c# application that connects to a PI Collective.

Since PI Points can be created or edited only on the primary member of a PI Collective, my goal is to verify that the primary member of the collective is available and connected before creating new Tags using the method PIServer.CreatePIPoint.

And in case the primary is unavailable, the application will store these tags in a list until the primary is available again.

 

When simulating a primary server disconnection using the standalone command:

piartool -sys -standalone on

and debugging the following condition in my code that checks if primary is connected

PIServer.Collective.ConnectedMemberType == AFServerRole.Primary

I revealed that the ConnectedMemberType flag is not set to the correct state, since it was still set to ConnectedMemberType.primary, even though the primary was unavailable.

Since I want to prevent a state where new tags or edited tags are not updated on the collective and are lost because the primary is unavailable, I would like to know:

 

What is the best and reliable way to confirm that the primary member is connected/available for updating tags editing\adding\deleting?

Would it be a good approach to use PICollectiveMember.Connect Method with 'RequirePrimary' parameter:

myPIServer.Connect(true, null, AFConnectionPreference.RequirePrimary);
If yes, then how can I verify that a connection to the primary is indeed established?

Outcomes