AnsweredAssumed Answered

Basics of the AF SDK

Question asked by andrew_Inwood on Sep 9, 2017
Latest reply on Jun 13, 2018 by Eugene Lee
Branched to a new discussion

I am new to the PI AF SDK (previously used the PI SDK, and before that, the API).

 

I was playing around using some examples, and used this example as a starting point:

https://techsupport.osisoft.com/Documentation/PI-AF-SDK/html/T_OSIsoft_AF_PI_PIPoint.htm

 

The code I am following is this code:

// Get the PIPoint from the PIServer on the local computer
PISystems myPISystems = new PISystems();
PISystem myPISystem = myPISystems.DefaultPISystem;
PIServer myPIServer = PIServer.FindPIServer(myPISystem, piServerName);
PIPoint myPIPoint = PIPoint.FindPIPoint(myPIServer, piPointName);
// Display information about the PIPoint
Console.WriteLine("Name of the PIPoint = {0}", myPIPoint.Name);
Console.WriteLine("ID of the PIPoint = {0}", myPIPoint.ID);
Console.WriteLine("Type of the PIPoint = {0}", myPIPoint.PointType);
Console.WriteLine("PIPoint Current Value = '{0}'", myPIPoint.CurrentValue());

 

This code is all very straight-forward, but I have a few questions related to it.

1.) A link to the PIServer can be found and linked without any reference to myPISystems or myPiSystem, by using the alternative overload ( PIServer myPIServer = PIServer.FindPIServer(serverName);).  A PIPoint can be found and it's value retrieved with only a reference to a myPIServer.  What is the point of first couple of lines of code?  Why is the myPISystems and myPISystem required?

 

2.) I note that PISystem implements IDisposable, but PISystems doesn't.  This is not intuitive to me.  PIServer also does not require IDisposable.  I guess something under the hood sets these requirements, but I figured that a PIServer was similar to a database, so might need to implement IDisposable, but clearly it doesn't.

Outcomes