I would like to know: How can I retrieve a point's digital state set using AF-SDK? Not only the state set name, but the whole set object.
There's several little calls that must wrapped together to make this happen. I offer the following as a extension method. You can convert to a regular method by omitting the word this in the signature:
Normally I would offer comments to explain what's going on, but really the code is straightforward enough.
public static AFEnumerationSet GetStateSet(this PIPoint tag)
if (tag == null || tag.PointType != PIPointType.Digital)
string digitalSetName = tag.GetAttribute(PICommonPointAttributes.DigitalSetName).ToString();
Line 11 could be done in many ways. The key is that GetAttribute returns a System.Object. Getting the digital set name would naturally be a string, but the PIServer casts it as an Object for GetAttribute, which you want to be cast back to String again. Besides using ToString(), either of these 2 would also work:
Helpful AF SDK links to learn more.
PIPoint.GetAttributes (bulk) method
Note the returned "state set" is actually an AFEnumerationSet. You may be curious to ask more about how to get values from this, but I would encourage you to learn to read how to do this on your own.
Nice one Rick! I will definitely add this extension method to my collection.
Retrieving data ...