IMD SolutionComputing LibraryShop main store

Troubleshooting

Why your AF SDK code cannot create a PI collective

Edge computing and IIoT Published 6 min read By IMD Solution engineering team

Short answer

AF SDK code cannot create a PI Data Archive collective or set its primary. PI Collective Manager on the server side defines membership; the PIServers object only exposes the workstation's known servers table, where a null Collective property means the selected entry is a standalone archive. Configure the collective administratively, then let PI Buffering fan your writes to every member.

On this page
  1. Collective membership is defined on the server, not in code
  2. What PIServers actually returns
  3. Filtering destinations without touching the KST
  4. Who replicates definitions and who fans out samples
  5. Selective delivery to two of five servers
  6. Filtering a five-entry known servers table on a 2016 AF SDK client
  7. The decision, in order
  8. Questions asked

Your application cannot create a PI collective, and no AF SDK code will change that. Collective membership and the primary member are server-side administrative settings made in PI Collective Manager; the AF SDK can only discover and connect to what already exists. The fix is to define the collective with the vendor's management tool, point your application at the collective's name through the workstation's known servers table, and run PI Buffering on the writing workstation so every member receives the data. This article separates the three layers that look like one problem: who defines the collective, how your C# code discovers destinations, and how writes reach all members.

Collective membership is defined on the server, not in code #

PI Collective Manager on the PI Data Archive host is the tool that creates and manages a collective. You select File > Create New Collective and the wizard walks you through the primary member and the initial member list; adding or removing a member afterwards is a matter of selecting Add Member and entering the member's host name. The primary member you choose there is the role your code cannot assign.

Once the collective exists, the primary propagates server configuration changes to the members. Create PI points, StateSets and other configuration objects on the primary, and replication carries those definitions to every member. Your application writes points and data; it does not own topology.

What PIServers actually returns #

The PIServers() constructor reads the known servers table (KST) on the workstation. The KST is a per-machine list of Data Archive and AF server destinations that client applications use for connections; it can hold standalone servers and entries that represent collectives side by side. Five entries in the table mean five known destinations, not five members of one collective.

An entry that represents a collective still returns a PIServer object, not a PICollective. Inspect the returned object's Collective property to reach the collective information. A null means the entry is a standalone archive:

What you observe What it means What to check next
dataServer.Collective == null The selected KST entry is a standalone archive The collective has not been created, or the XML names a standalone server
A utility connects to five servers Five known destinations exist on this workstation Whether they are standalone or members of one collective
Your collectives-only filter yields an empty list No known entry represents a collective The workstation's KST and the server-side configuration
CurrentMember.Name is not the expected primary The collective connection is on another member The member role with CurrentMember.ServerRole

A null Collective is a destination-selection or topology finding, not a point or tag fault. Changing a point name cannot turn a standalone archive into a collective.

Filtering destinations without touching the KST #

Do not call Clear and Add on PIServers to limit what the application shows. The KST is workstation-level configuration shared by every client on that machine; a filtered server list is application-level policy. Filter the enumeration and leave the table alone. If you write against collective members over buffering, the page on troubleshooting AF SDK writes to PI collective members covers the delivery side in depth.

For your console application, keep the XML simple. One configured collective destination needs exactly one name in the XML; several permitted destinations need a name list the user picks from, resolved only after the selection. Filter for collectives-only by keeping entries where Collective != null, and handle an empty result explicitly rather than falling back to a standalone archive.

For the connection path from a C# application to PI generally, the article on the AF SDK as the native path from C# to PI walks through the assembly and connection basics.

Who replicates definitions and who fans out samples #

Configuration and time-series travel by different mechanisms:

Operation Responsible component Consequence
Create or modify point definitions Primary member, with collective configuration replication Make configuration changes on the primary
Deliver buffered tag values PI Buffer service on the writing workstation One write is fanned to every member
Write without buffering The application's selected connection only No automatic fan-out to members
Write to several standalone servers Custom application code Your code owns delivery tracking and recovery

This is the correction to the usual mental model: data does not flow from primary to members. Writes go to the PI Buffer service on the workstation, and that service fans each sample to all members of the collective. Without buffering running, a successful write to the primary reaches only the primary, and the members silently fall behind. A successful primary write proves the selected path accepted the operation; it does not prove every member has the sample.

Selective delivery to two of five servers #

If you have five known servers and want data on only two of them, first identify the topology. Two members of one collective are not the same as two standalone destinations in a five-entry KST. A collective delivers to all of its members or is not a collective; there is no per-member sampling switch. For selective delivery to independent servers, build the fan-out in the application: open connections to the intended destinations, write to each, and track per-server failures and recovery yourself. PI Collective Manager is the wrong tool for that requirement, because membership decisions belong to high-availability design, not to per-server filtering.

Filtering a five-entry known servers table on a 2016 AF SDK client #

Inputs: a workstation whose KST holds five destinations (the reader's own case), the AF SDK 2016 assembly referenced by the console application, and PIServers as the documented entry point that returns every destination in the table. The rule: enumerate the known destinations and keep only those whose Collective property is not null, because a non-null value identifies an entry that represents a configured collective.

// Illustrative fragment; add the usual AF SDK, collections and LINQ references.
PIServers kst = new PIServers();
List<PIServer> filtered = kst.Where(pida => pida.Collective != null).ToList();

Arithmetic on the reader's case: the table holds five entries; the filter keeps entries with a non-null Collective; if the collective named PIServer01 exists and the other four entries are standalone archives, the filter keeps five minus four, which is one entry. If the collective does not exist server-side, the filter keeps five minus five, which is zero.

Result: a list of zero or more collective destinations, possibly empty.

Decision: an empty list means create the collective in PI Collective Manager first and reconnect; a list with one entry means put that collective's name in the XML and let buffering deliver the writes; a list with several entries means present them to the user and resolve only the chosen name.

The decision, in order #

  1. Define the collective, its members and its primary in PI Collective Manager on the server host. This is the only place membership is set.
  2. Install and configure PI Buffering on every workstation that writes, so each write is fanned to all members.
  3. In the application, resolve one collective name from the XML through PIServers, inspect Collective, and filter known servers for choices rather than editing the KST.
  4. For delivery to a subset of independent servers, implement the fan-out in application code; no collective configuration produces selective delivery.

AF SDK member operations such as SwitchMember on a PICollective or ConnectDirect on a PICollectiveMember change which member a connection talks to. They solve connection selection. They do not create collectives, set the primary, or distribute data.

One safety note: writes that reach only some members can leave control or compliance logic reading stale values from the member it happens to hit. Verify buffering end to end before any process depends on collective redundancy.

Questions asked

Can my C# application set which collective member is the primary?

No. The primary member is a server-side role assigned when the collective is created or edited in PI Collective Manager on the PI Data Archive host. The AF SDK exposes the collective as it is configured and lets the client choose which member to talk to, for example through SwitchMember or ConnectDirect on a PICollectiveMember, but it does not change membership or roles.

My console app reads one server name from an XML file. How do I move it to a collective?

Create the collective in PI Collective Manager, add each member host name, and install PI Buffering on the workstation that runs the application. Then put the collective's known server name in the XML instead of a member's name. The application code stays the same: it resolves that one name through PIServers, and the buffering service delivers each write to all members.

Does a successful write to the primary prove the members received the data?

Not by itself. Without the PI Buffer service running on the writing workstation, a write reaches only the server the connection selected; there is no automatic fan-out from the primary to members. Verify delivery per member by connecting directly to each one and reading back a known tag, value and timestamp, and keep the buffering subnets identical on every member so the fan-out is complete.

Keep reading

  • Troubleshooting

    Why historian output writes stop on a secondary server

    Output writes stop because the interface keeps pulling source-tag events from its configured /host server, and a single PI-model interface instance does not search the collective for another member. Buffering only covers the interface-to-server direction, which is why inputs keep logging. Point the standby interface's /host at the secondary member, confirm the source-tag events reach it, and prove the subscription with pilistupd.

    Edge computing and IIoT

  • How-to

    Deploying PI AF and PI Vision across two Windows domains

    Keep the PI Data Archive, the AF server, PI Vision and the SQL Server hosting its database in one domain when you can. If the archive stays in Domain A, treat Domain B as an identity design: set the trust direction, choose service identity or Kerberos delegation, and prove all five connections from their originating hosts.

    Edge computing and IIoT

  • Troubleshooting

    Fix a DeltaV embedded trend that shows no PI history

    The error names the chart's own PI history connection, PI1, failing to open — the data is not missing. Process History View working on the same workstation proves the server, network and stored interval are good, so stop cycling hostname, IP and defaulthost and reconcile the chart's Historical Data Server entry and the PI1 connection definition against the viewer's working path.

    Edge computing and IIoT

Tag Browse Tree missing from your designer palette